﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using vm.Aspects;

namespace vm.Aspects.Tests
{
    [TestClass]
    public class ExtensionsTest
    {
        [TestMethod]
        public void TestEqualsByValueNulls()
        {
            int[] array1 = null;
            int[] array2 = null;

            Assert.IsTrue(array1.EqualsByValue(array2));
            Assert.IsTrue(array2.EqualsByValue(array1));
        }

        [TestMethod]
        public void TestEqualsByValueNullNotNull()
        {
            int[] array1 = null;
            int[] array2 = new int[] { 1, 2, 3 };

            Assert.IsFalse(array1.EqualsByValue(array2));
            Assert.IsFalse(array2.EqualsByValue(array1));
        }

        [TestMethod]
        public void TestEqualsByValueDiffLengths()
        {
            int[] array1 = new int[] { 1, 2, 3, 4 };
            int[] array2 = new int[] { 1, 2, 3 };

            Assert.IsFalse(array1.EqualsByValue(array2));
            Assert.IsFalse(array2.EqualsByValue(array1));
        }

        [TestMethod]
        public void TestEqualsByValueDiffElements()
        {
            int[] array1 = new int[] { 1, 2, 4 };
            int[] array2 = new int[] { 1, 2, 3 };

            Assert.IsFalse(array1.EqualsByValue(array2));
            Assert.IsFalse(array2.EqualsByValue(array1));
        }

        [TestMethod]
        public void TestEqualsByValueNotNulls()
        {
            int[] array1 = new int[] { 1, 2, 3 };
            int[] array2 = new int[] { 1, 2, 3 };

            Assert.IsTrue(array1.EqualsByValue(array2));
            Assert.IsTrue(array2.EqualsByValue(array1));
        }

        [TestMethod]
        public void TestEqualsByValueTranspose()
        {
            int[] array1 = new int[] { 1, 2, 3 };
            int[] array2 = new int[] { 1, 2, 3 };
            int[] array3 = new int[] { 1, 2, 3 };

            Assert.IsTrue(array1.EqualsByValue(array2));
            Assert.IsTrue(array2.EqualsByValue(array3));
            Assert.IsTrue(array1.EqualsByValue(array3));
        }
    }
}
